package tokens;

import java.util.ListIterator;
import java.util.Queue;
import java.util.Stack;

import parser.ParserException;

import nodes.AbstractNode;
import nodes.binary.AndNode;
import nodes.binary.GreaterNode;
/**
 * Creates a GreaterToken to be used by the Parser
 * 
 * 
 * @author Charlie Hatcher
 */
public class GreaterToken extends AbstractBinaryToken{
	private static final String GREATER_TOKEN = "\\>";

	public GreaterToken(){
		precedence = 1;
	}
	@Override
	public AbstractNode process() {
		return new GreaterNode(myModel);
	}

	

	@Override
	public boolean matchToken(String str, ListIterator<String> it) {
		return str.matches(GREATER_TOKEN);
	}
	
	public String toString(){
		return syntaxBundle.getString("greater_than_label");
	}
	@Override
	public void handleParser(String str, ListIterator<String> it,
			Stack<AbstractBinaryToken> opStack,
			Queue<AbstractNode> outPutQueue, Queue<AbstractNode> queue)
			throws Exception {
		if(!outPutQueue.isEmpty()){
			AbstractNode temp = outPutQueue.poll();
			outPutQueue.add(new GreaterToken().process());
			outPutQueue.add(temp);
		}
		else throw ParserException.BAD_SYNTAX; 
		
	}

}
